package util;

import exception.AncException;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * @author xiongyx
 * @date 2020/6/4
 */
public class URLCodecUtil {

    public static String urlEncode(String str, String charset){
        try {
            return URLEncoder.encode(str,charset);
        } catch (UnsupportedEncodingException e) {
            throw new AncException("urlEncode error",e);
        }
    }

    public static String urlDecode(String str, String charset){
        try {
            return URLDecoder.decode(str,charset);
        } catch (UnsupportedEncodingException e) {
            throw new AncException("urlDecode error",e);
        }
    }
}
